﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using VanTaiBLL;
using VanTaiData;
using VanTaiProperty;
using Roles;
using System.Web.UI.HtmlControls;

namespace VanTaiTMS.Page
{
    public partial class nhat_ky_hanh_trinh : System.Web.UI.Page
    {
        #region[Define]
        private DataTable dtDiary;
        private DataTable dtDiaryDetail;
        private DataTable dtDiaryFillter;
        private DataTable dtVehicle;
        private DataTable dtEmployer;
        private DataTable dtDesFrom;
        private DataTable dtDesTo;
        private DataTable dtSearch;
        protected string SuggestionList;
        protected string StrAlert = "";
        private DataTable dtAutoComplete;
        private static bool flag = false;
        private clsTMDiaryTransferOrderBusiness clsDiary = new clsTMDiaryTransferOrderBusiness();
        private clsTMVehicleBusiness clsXe = new clsTMVehicleBusiness();
        private clsTMMemberBusiness clsDMNhanVien = new clsTMMemberBusiness();
        private clsTMDeliveryBusiness clsNoiGiaoHang = new clsTMDeliveryBusiness();
        #endregion

        #region[Controller]
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckPermisstion();
            Autocomplate();
            if (!IsPostBack)
            {
                BindGridDiary();
                BindGridVehicle();
                BindGridEmployer();
                BindGridDes();
            }
        }
        protected void cmdAddNew_Click(object sender, EventArgs e)
        {
            flag = true;
            lbThongBaoLoi.Text = "";
            ClearTextBox();
            ClearDropdownlist();
            OpenDialog("#nhatkyhanhtrinh");
            imgSave.ToolTip = "Thêm mới";
            upNewUpdatePanel.Update();
            imgSave.Visible = true;
        }
        protected void cmdEdit_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < ListViewAll.Items.Count; i++)
            {
                CheckBox chkView = (CheckBox)ListViewAll.Items[i].FindControl("chkList");
                Label lbTrangThai = (Label)ListViewAll.Items[i].FindControl("lbDuyet");
                if (chkView != null)
                {
                    if (chkView.Checked)
                    {
                        BindGridDiarytDetail_Edit(Convert.ToInt32(ListViewAll.DataKeys[i].Value.ToString()));
                        OpenDialog("#nhatkyhanhtrinh");
                        upNewUpdatePanel.Update();
                        imgSave.ToolTip = "Cập nhật";
                        flag = false;
                    }
                }
            }
        }
        protected void cmdDel_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < ListViewAll.Items.Count; i++)
            {
                CheckBox chkHide = (CheckBox)ListViewAll.Items[i].FindControl("chkList");
                Label lbTrangThai = (Label)ListViewAll.Items[i].FindControl("lbDuyet");
                if (chkHide != null)
                {
                    if (chkHide.Checked)
                    {
                        try
                        {
                            VanTaiBLL.clsTMDiaryTransferOrderBusiness.DeleteTMDiaryTransferOrder(int.Parse(ListViewAll.DataKeys[i].Value.ToString()));
                            BindGridDiary();
                        }
                        catch (Exception ex)
                        {
                            lbThongBaoXoa.Text = ex.ToString();
                            OpenDialog("#thongbaoxoa");
                            upDatePanelThongBaoXoa.Update();
                            cmdAgree.Visible = false;
                            cmdClose.Text = "Đóng lại";
                        }
                    }
                }
            }
        }
        protected void cmdSerach_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text == "")
            {
                StrAlert += "<div class='alert alert-warning'>";
                StrAlert += "<a href='#' class='close' data-dismiss='alert'>&times;</a>";
                StrAlert += "Vui lòng nhập vào từ khoá để tìm kiếm !";
                StrAlert += "</div>";
            }
            else
            {
                Search(txtSearch.Text);
            }
        }
        protected void cmdRefesh_Click(object sender, EventArgs e)
        {
            txtSearch.Text = "";
            txtTuNgayNgayNhapKho.Text = "";
            txtDenNgayNhapKho.Text = "";
            BindGridDiary();
        }
        protected void cmdExport_Click(object sender, EventArgs e)
        {
            OpenDialog("#exporttoexcel");
        }
        protected void cmdExportToExcel_Click(object sender, EventArgs e)
        {
            //if (txtNameReport.Text == "")
            //{
            //    lbThongBaoLoi.Text = "Vui lòng nhập vào tên tập tin để xuất ra tập tin bảng tính !";
            //    OpenDialog("#thongbao");
            //    updatePanelThongBao.Update();
            //}
            //else
            //{
            //    Response.Clear();
            //    Response.AddHeader("content-disposition", "attachment;filename=" + txtNameReport.Text + ".xls");
            //    Response.Charset = "";
            //    Response.ContentType = "application/vnd.xls";
            //    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            //    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            //    PaneViewData.RenderControl(htmlWrite);
            //    HttpContext.Current.Response.Write(stringWrite.ToString());
            //    HttpContext.Current.Response.End();
            //    upDatePanelExportToExcel.Update();
            //}
        }
        protected void cmdFilter_Click(object sender, EventArgs e)
        {
            Fillter(txtTuNgayNgayNhapKho.Text, txtDenNgayNhapKho.Text);
        }
        //---------------button-popup---------------------
        protected void imgrefesh_Click(object sender, ImageClickEventArgs e)
        {

        }
        protected void imgSave_Click(object sender, ImageClickEventArgs e)
        {
            if (txtNgayGio.Text == "")
            {
                lbThongBaoLoi.Text = "Vui lòng điền vào ngày giờ !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (drSoXe.SelectedValue.ToString() == "-1")
            {
                lbThongBaoLoi.Text = "Vui lòng chọn số xe !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (drTaiXe.SelectedValue.ToString() == "-1")
            {
                lbThongBaoLoi.Text = "Vui lòng chọn tài xế !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (drNgayDen.SelectedValue.ToString() == "-1")
            {
                lbThongBaoLoi.Text = "Vui lòng chọn điểm đến !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (drNgayDi.SelectedValue.ToString() == "-1")
            {
                lbThongBaoLoi.Text = "Vui lòng chọn điểm đi !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (txtNhatKy.Text == "")
            {
                lbThongBaoLoi.Text = "Vui lòng điền vào nhật ký !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
            if (txtNgayGio.Text != "" && txtNhatKy.Text != "" && drSoXe.SelectedValue.ToString() != "-1" && drTaiXe.SelectedValue.ToString() != "-1" && drNgayDen.SelectedValue.ToString() != "-1" && drNgayDi.SelectedValue.ToString() != "-1")
            {
                Insert();
            }
        }
        protected void cmdAgree_Click(object sender, EventArgs e)
        {
            
        }
        protected void cmdClose_Click(object sender, EventArgs e)
        {
            CloseDialog("#thongbaoxoa");
        }
        protected void cmdCloseThongBao_Click(object sender, EventArgs e)
        {
            CloseDialog("#thongbao");
        }
        protected void ImgRefeshDuyet_Click(object sender, ImageClickEventArgs e)
        {

        }
        protected void ImgRefeshExport_Click(object sender, ImageClickEventArgs e)
        {
            //txtTuNgayNhapKhoExport.Text = "";
            //txtDenNgayNhapKhoExport.Text = "";
            //BindGridLenhDieuDongExportExcel();
        }
        //-------------list-view-----------------------
        protected void ListViewAll_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            try
            {
                HttpCookie cookie = Request.Cookies["UserLogin"];
                bool Edit = SecurityServices.HasPermisstion(StringContent.QuanLyNhatKyHanhTrinh, int.Parse(cookie["RolesID"]), TypeaAudit.Edit);
                lbThongBaoLoi.Text = "";
                if (e.CommandName == "Accept" || e.CommandName == "Accept_A" || e.CommandName == "Accept_B" ||
                    e.CommandName == "Accept_C" || e.CommandName == "Accept_D" || e.CommandName == "Accept_E")
                {
                    if (Edit == false)
                    {
                        imgSave.Visible = false;
                        string SenderId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
                        BindGridDiarytDetail_Edit(int.Parse(SenderId));
                        OpenDialog("#nhatkyhanhtrinh");
                        upNewUpdatePanel.Update();
                        imgSave.ToolTip = "Cập nhật";
                        flag = false;
                    }
                    else
                    {
                        imgSave.Visible = true;
                        string SenderId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
                        BindGridDiarytDetail_Edit(int.Parse(SenderId));
                        OpenDialog("#nhatkyhanhtrinh");
                        upNewUpdatePanel.Update();
                        imgSave.ToolTip = "Cập nhật";
                        flag = false;
                    }
                }
            }
            catch (Exception ex)
            {
                lbThongBaoLoi.Text = ex.ToString();
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
        }
        protected void ListViewAll_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                LinkButton linkListName = (LinkButton)e.Item.FindControl("linkListName");
                LinkButton linkListName_A = (LinkButton)e.Item.FindControl("linkListName_A");
                LinkButton linkListName_B = (LinkButton)e.Item.FindControl("linkListName_B");
                LinkButton linkListName_C = (LinkButton)e.Item.FindControl("linkListName_C");
                LinkButton linkListName_D = (LinkButton)e.Item.FindControl("linkListName_D");
                LinkButton linkListName_E = (LinkButton)e.Item.FindControl("linkListName_E");

                string _jsDouble1 = ClientScript.GetPostBackClientHyperlink(linkListName, "");
                string _jsDouble2 = ClientScript.GetPostBackClientHyperlink(linkListName_A, "");
                string _jsDouble3 = ClientScript.GetPostBackClientHyperlink(linkListName_B, "");
                string _jsDouble4 = ClientScript.GetPostBackClientHyperlink(linkListName_C, "");
                string _jsDouble5 = ClientScript.GetPostBackClientHyperlink(linkListName_D, "");
                string _jsDouble6 = ClientScript.GetPostBackClientHyperlink(linkListName_E, "");

                linkListName.Attributes["ondblclick"] = _jsDouble1;
                linkListName.Attributes["onclick"] = "return false;";

                linkListName_A.Attributes["ondblclick"] = _jsDouble2;
                linkListName_A.Attributes["onclick"] = "return false;";

                linkListName_B.Attributes["ondblclick"] = _jsDouble3;
                linkListName_B.Attributes["onclick"] = "return false;";

                linkListName_C.Attributes["ondblclick"] = _jsDouble4;
                linkListName_C.Attributes["onclick"] = "return false;";

                linkListName_D.Attributes["ondblclick"] = _jsDouble5;
                linkListName_D.Attributes["onclick"] = "return false;";

                linkListName_E.Attributes["ondblclick"] = _jsDouble6;
                linkListName_E.Attributes["onclick"] = "return false;";
            }
        }
        //-----------pagger-----------------------
        protected void DataPagerListAll_PreRender(object sender, EventArgs e)
        {
            DataPagerListAll.PageSize = 17;
            BindGridDiary();
        }
        //---------Check-all--------------
        protected void chkCheckAll_CheckedChanged(object sender, EventArgs e)
        {

        }
        //---------DropDownlist---------------------
        protected void drTrangThai_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        protected void drSoXe_SelectedIndexChanged(object sender, EventArgs e)
        {
            //BindGridNhomXe(int.Parse(drSoXe.SelectedValue.ToString()));
            //BindGridTaiXe(int.Parse(drSoXe.SelectedValue.ToString()));
        }
        protected void drTaiXe_SelectedIndexChanged(object sender, EventArgs e)
        {
            //drNhomXe.Enabled = true;
        }
        #endregion

        #region[Function]
        protected void BindGridDiary()
        {
            dtDiaryFillter = clsDiary.Fillter_Date(txtTuNgayNgayNhapKho.Text, txtDenNgayNhapKho.Text);
            dtDiary = clsDiary.Search(txtSearch.Text);
            if (txtTuNgayNgayNhapKho.Text == "" && txtDenNgayNhapKho.Text == "")
            {
                if (dtDiary != null && dtDiary.Rows.Count > 0)
                {
                    ListViewAll.DataSource = dtDiary;
                    ListViewAll.DataBind();
                    ListViewAll.Visible = true;
                    DataPagerListAll.Visible = true;
                }
                else
                {
                    ListViewAll.Visible = false;
                    DataPagerListAll.Visible = false;
                }
            }
            else
            {
                if (dtDiaryFillter != null && dtDiaryFillter.Rows.Count > 0)
                {
                    ListViewAll.DataSource = dtDiaryFillter;
                    ListViewAll.DataBind();
                    ListViewAll.Visible = true;
                    DataPagerListAll.Visible = true;
                }
            }
        }
        protected void BindGridDiarytDetail_Edit(int id)
        {
            dtDiaryDetail = clsDiary.BindGirdTMDelivery_Detail_Edit(id);
            if (dtDiaryDetail != null && dtDiaryDetail.Rows.Count > 0)
            {
                lbID.Text = dtDiaryDetail.Rows[0]["DiaryTrans_ID"].ToString();
                lbIDXoa.Text = dtDiaryDetail.Rows[0]["DiaryTrans_ID"].ToString();
                txtNgayGio.Text = dtDiaryDetail.Rows[0]["DiaryTrans_Date"].ToString();
                drSoXe.SelectedValue = dtDiaryDetail.Rows[0]["DiaryTrans_Vehicle_ID"].ToString();
                drTaiXe.SelectedValue = dtDiaryDetail.Rows[0]["DiaryTrans_Member_ID"].ToString();
                drNgayDen.SelectedValue = dtDiaryDetail.Rows[0]["DiaryTrans_From_ID"].ToString();
                drNgayDi.SelectedValue = dtDiaryDetail.Rows[0]["DiaryTrans_To_ID"].ToString();
                txtNhatKy.Text = dtDiaryDetail.Rows[0]["DiaryTrans_Log"].ToString();
                txtGhiChu.Text = dtDiaryDetail.Rows[0]["DiaryTrans_Note"].ToString();
            }
        }
        protected void BindGridVehicle()
        {
            dtVehicle = clsXe.BindGirdTMVehicle();
            if (dtVehicle != null && dtVehicle.Rows.Count > 0)
            {
                drSoXe.DataSource = dtVehicle;
                drSoXe.DataTextField = "Vehicle_Number";
                drSoXe.DataValueField = "Vehicle_ID";
                drSoXe.DataBind();
            }
        }
        protected void BindGridEmployer()
        {
            dtEmployer = clsDMNhanVien.BindGirdTMMember();
            if (dtEmployer != null && dtEmployer.Rows.Count > 0)
            {
                drTaiXe.DataSource = dtEmployer;
                drTaiXe.DataTextField = "FullNameMem";
                drTaiXe.DataValueField = "Member_ID";
                drTaiXe.DataBind();
            }
        }
        protected void BindGridDes()
        {
            dtDesFrom = clsNoiGiaoHang.BindGirdTMDelivery();
            dtDesTo = clsNoiGiaoHang.BindGirdTMDelivery();
            if (dtDesFrom != null && dtDesFrom.Rows.Count > 0)
            {
                drNgayDen.DataSource = dtDesFrom;
                drNgayDen.DataTextField = "Delivery_Name";
                drNgayDen.DataValueField = "Delivery_ID";
                drNgayDen.DataBind();
            }

            if (dtDesTo != null && dtDesTo.Rows.Count > 0)
            {
                drNgayDi.DataSource = dtDesTo;
                drNgayDi.DataTextField = "Delivery_Name";
                drNgayDi.DataValueField = "Delivery_ID";
                drNgayDi.DataBind();
            }
        }
        protected void Insert()
        {
            //Insert
            if (flag)
            {
                InsertDiary();
            }
            else//Update
            {
                UpdateDiary();
            }
        }
        protected void InsertDiary()
        {
            try
            {
                VanTaiProperty.clsTMDiaryTransferOrderProperty obj = new clsTMDiaryTransferOrderProperty();
                obj.DiaryTrans_Date = DateTime.Parse(txtNgayGio.Text);
                obj.DiaryTrans_Vehicle_ID = int.Parse(drSoXe.SelectedValue.ToString());
                obj.DiaryTrans_Member_ID = int.Parse(drTaiXe.SelectedValue.ToString());
                obj.DiaryTrans_From_ID = int.Parse(drNgayDen.SelectedValue.ToString());
                obj.DiaryTrans_To_ID = int.Parse(drNgayDi.SelectedValue.ToString());
                obj.DiaryTrans_Log = txtNhatKy.Text;
                obj.DiaryTrans_Note = txtGhiChu.Text;
                VanTaiBLL.clsTMDiaryTransferOrderBusiness.InsertTMDiaryTransferOrder(obj);
                lbThongBaoLoi.Text = "Thêm mẫu tin thành công !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
                BindGridDiary();
                ClearTextBox();
                ClearDropdownlist();
            }
            catch (Exception ex)
            {
                lbThongBaoLoi.Text = ex.ToString();
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
        }
        protected void UpdateDiary()
        {
            try
            {
                VanTaiProperty.clsTMDiaryTransferOrderProperty obj = new clsTMDiaryTransferOrderProperty();
                obj.DiaryTrans_ID = int.Parse(lbID.Text);
                obj.DiaryTrans_Date = DateTime.Parse(txtNgayGio.Text);
                obj.DiaryTrans_Vehicle_ID = int.Parse(drSoXe.SelectedValue.ToString());
                obj.DiaryTrans_Member_ID = int.Parse(drTaiXe.SelectedValue.ToString());
                obj.DiaryTrans_From_ID = int.Parse(drNgayDen.SelectedValue.ToString());
                obj.DiaryTrans_To_ID = int.Parse(drNgayDi.SelectedValue.ToString());
                obj.DiaryTrans_Log = txtNhatKy.Text;
                obj.DiaryTrans_Note = txtGhiChu.Text;
                VanTaiBLL.clsTMDiaryTransferOrderBusiness.UpdateTMDiaryTransferOrder(obj);
                lbThongBaoLoi.Text = "Cập nhật mẫu tin thành công !";
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
                BindGridDiarytDetail_Edit(int.Parse(lbID.Text));
            }
            catch (Exception ex)
            {
                lbThongBaoLoi.Text = ex.ToString();
                OpenDialog("#thongbao");
                updatePanelThongBao.Update();
            }
        }
        protected void Fillter(string DateBegin, string EndBegin)
        {
            dtDiaryFillter = clsDiary.Fillter_Date(txtTuNgayNgayNhapKho.Text, txtDenNgayNhapKho.Text);
            if (dtDiaryFillter != null && dtDiaryFillter.Rows.Count > 0)
            {
                ListViewAll.DataSource = dtDiaryFillter;
                ListViewAll.DataBind();
                ListViewAll.Visible = true;
                DataPagerListAll.Visible = true;

                StrAlert += "<div class='alert alert-success'>";
                StrAlert += "<a href='#' class='close' data-dismiss='alert'>&times;</a>";
                StrAlert += "Tìm thấy " + dtDiaryFillter.Rows.Count.ToString() + " mẫu tin !";
                StrAlert += "</div>";
            }
            else
            {
                ListViewAll.Visible = false;
                DataPagerListAll.Visible = false;

                StrAlert += "<div class='alert alert-error'>";
                StrAlert += "<a href='#' class='close' data-dismiss='alert'>&times;</a>";
                StrAlert += "Không tìm thấy mẫu tin nào !";
                StrAlert += "</div>";
            }
        }

        //AutoComplate
        protected void Autocomplate()
        {
            dtAutoComplete = clsDiary.BindGirdTMDiaryTransferOrder();
            if (dtAutoComplete != null && dtAutoComplete.Rows.Count > 0)
            {
                foreach (DataRow dr in dtAutoComplete.Rows)
                {
                    if (string.IsNullOrEmpty(SuggestionList))
                    {
                        SuggestionList += "\"" + dr["Vehicle_Number"].ToString().Replace("\n", " ") + "\",";
                        SuggestionList += "\"" + dr["FullNameMem"].ToString().Replace("\n", " ") + "\",";
                    }
                    else
                    {
                        SuggestionList += "\"" + dr["Vehicle_Number"].ToString().Replace("\n", " ") + "\",";
                        SuggestionList += "\"" + dr["FullNameMem"].ToString().Replace("\n", " ") + "\",";
                    }
                }
            }
        }
        protected void Search(string keywords)
        {
            dtSearch = clsDiary.Search(keywords);
            if (dtSearch != null && dtSearch.Rows.Count > 0)
            {
                ListViewAll.DataSource = dtSearch;
                ListViewAll.DataBind();
                ListViewAll.Visible = true;
                DataPagerListAll.Visible = true;

                StrAlert += "<div class='alert alert-success'>";
                StrAlert += "<a href='#' class='close' data-dismiss='alert'>&times;</a>";
                StrAlert += "Tìm thấy " + dtSearch.Rows.Count.ToString() + " mẫu tin !";
                StrAlert += "</div>";
            }
            else
            {
                ListViewAll.Visible = false;
                DataPagerListAll.Visible = false;
                StrAlert += "<div class='alert alert-error'>";
                StrAlert += "<a href='#' class='close' data-dismiss='alert'>&times;</a>";
                StrAlert += "Không tìm thấy mẫu tin nào !";
                StrAlert += "</div>";
            }
        }
        //Total
        #endregion

        #region[OpenDialog]
        private void OpenDialog(string dialogId)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("$('" + dialogId + "').dialog('open');");
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
               "scriptKey", sb.ToString(), true);
        }
        private void CloseDialog(string dialogId)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("$('" + dialogId + "').dialog('close');");
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
               "scriptKey", sb.ToString(), true);
        }
        #endregion

        #region[Clear-TextBox]
        protected void ClearTextBox()
        {
            txtNgayGio.Text = DateTime.Now.ToString();
            txtNhatKy.Text = "";
            txtGhiChu.Text = "";
        }
        protected void ClearDropdownlist()
        {
            drSoXe.SelectedIndex = -1;
            drTaiXe.SelectedIndex = -1;
            drNgayDen.SelectedIndex = -1;
            drNgayDi.SelectedIndex = -1;
        }
        #endregion

        #region[Permisstion]
        protected void CheckPermisstion()
        {
            HttpCookie cookie = Request.Cookies["UserLogin"];
            if (cookie != null)
            {
                bool Is_Page_All = SecurityServices.HasPermisstionPage(StringContent.QuanLyNhatKyHanhTrinh, int.Parse(cookie["RolesID"]), true);
                if (Is_Page_All == true)
                {
                    bool AddNew = SecurityServices.HasPermisstion(StringContent.QuanLyNhatKyHanhTrinh, int.Parse(cookie["RolesID"]), TypeaAudit.AddNew);
                    if (AddNew == false)
                    {
                        cmdAddNew.Visible = false;
                    }
                    else
                    {
                        cmdAddNew.Visible = true;
                    }
                    bool Edit = SecurityServices.HasPermisstion(StringContent.QuanLyNhatKyHanhTrinh, int.Parse(cookie["RolesID"]), TypeaAudit.Edit);
                    if (Edit == false)
                    {
                        cmdEdit.Visible = false;
                    }
                    else
                    {
                        cmdEdit.Visible = true;
                    }
                    bool Del = SecurityServices.HasPermisstion(StringContent.QuanLyNhatKyHanhTrinh, int.Parse(cookie["RolesID"]), TypeaAudit.Delete);
                    if (Del == false)
                    {
                        cmdDel.Visible = false;
                    }
                    else
                    {
                        cmdDel.Visible = true;
                    }
                }
                else
                {
                    Response.Redirect("error-page.aspx");
                }
            }
        }
        #endregion
    }
}